package com.guducat.collegeWeb.dto.response;

import java.util.List;

/**
 * 分页结果数据传输对象
 * 用于封装分页查询结果
 * @param <T> 数据项类型
 */
public class PageResultDTO<T> {
    private List<T> list;      // 数据列表
    private long total;        // 总记录数
    private int pageNum;       // 当前页码
    private int pageSize;      // 每页记录数
    private int pages;         // 总页数

    public PageResultDTO() {
    }

    public PageResultDTO(List<T> list, long total, int pageNum, int pageSize) {
        this.list = list;
        this.total = total;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.pages = (int) Math.ceil((double) total / pageSize);
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }
}
